﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IEnemy : ICharacter
{
	public IEnemy()
	{ }

	public override void Attack(ICharacter target)
	{
		m_Weapon.ShowShootEffect();
		int atkPlusValue = 0;
		switch(m_Weapon.GetWeaponType())
		{
			case ENUM_Weapon.Gun:
				//显示武器特效
				m_Weapon.ShowBulletEffect(target.GetPosition(), 0.3f, 0.2f);
				m_Weapon.ShowSoundEffect("GunShot");
				atkPlusValue = GetAtkPluginValue(5, 20);
				break;
			case ENUM_Weapon.Rifle:
				m_Weapon.ShowBulletEffect(target.GetPosition(), 0.4f, 0.2f);
				m_Weapon.ShowSoundEffect("GunShot");
				atkPlusValue = GetAtkPluginValue(5, 20);
				break;
			case ENUM_Weapon.Rocket:
				m_Weapon.ShowBulletEffect(target.GetPosition(), 0.5f, 0.2f);
				m_Weapon.ShowSoundEffect("GunShot");
				atkPlusValue = GetAtkPluginValue(5, 20);
				break;
		}
		m_Weapon.SetAtkPlusValue(atkPlusValue);
		m_Weapon.Fire(target);
	}
	private int GetAtkPlusValue(int rate, int atkValue)
	{
		int randValue = UnityEngine.Random.Range(0, 100);
		if (rate > randValue)
			return atkValue;
		return 0;
	}
}
